/**
 * Created by Administrator on 2017/9/18/0018.
 */
define(function (require) {
    function execute() {
        var courseIntroduceContentP = document.getElementById("course-introduce-content"),
            userHandler = new require("userHandler").StudentHandler(),
            checkInDom = document.getElementById('check-in'),
            nowCourseDom = document.getElementById('now-course'),
            $ = require('jquery');
        require('jquery.cookie');

        // 签到
        checkInDom.addEventListener('click', function () {
            if (this.classList.contains('done')) return;
            var that = this;
            userHandler.checkIn($.cookie('courseId'), function () {
                that.classList.add('done');
                that.innerHTML = '已签到'
            }, function () {
                alert('签到失败')
            })
        });

        userHandler.getCourse($.cookie("courseId"), function (data) {
            courseIntroduceContentP.innerText = data.introduce;
            nowCourseDom.innerHTML = data.name;
        });

    }


    return {
        execute: execute
    }
})